package org.durandj.ystream.client.util;

import java.net.InetAddress;

/**
 * A utility class for working with the <code>InetAddress</code> class.
 * 
 * @author durandj
 * @version 1.0
 *
 */
public class InetAddressUtils
{
	/**
	 * The purpose of this method is to get a string representation of an address.
	 * This could be either the hostname if there is or the IP address if there's
	 * no defined hostname.
	 * 
	 * @param address - the address
	 * @return the hostname or the IP
	 */
	public static String getStringAddress(InetAddress address)
	{
		String tempString = address.toString();
		String tokens[] = tempString.split("/");
		
		return tokens[0].isEmpty() ? tokens[1]:tokens[0];
	}
}
